package edu.unf.cen6940.dao;

import edu.unf.cen6940.domain.Thesisstatus;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage Thesisstatus entities.
 * 
 */
@Repository("ThesisstatusDAO")
@Transactional
public class ThesisstatusDAOImpl extends AbstractJpaDao<Thesisstatus> implements
		ThesisstatusDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { Thesisstatus.class }));

	/**
	 * EntityManager injected by Spring for persistence unit rms
	 *
	 */
	@PersistenceContext(unitName = "rms")
	private EntityManager entityManager;

	/**
	 * Instantiates a new ThesisstatusDAOImpl
	 *
	 */
	public ThesisstatusDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findThesisstatusByDefended
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefended(String defended) throws DataAccessException {

		return findThesisstatusByDefended(defended, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByDefended
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefended(String defended, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByDefended", startResult, maxRows, defended);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByProposalPass
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalPass(String proposalPass) throws DataAccessException {

		return findThesisstatusByProposalPass(proposalPass, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByProposalPass
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalPass(String proposalPass, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByProposalPass", startResult, maxRows, proposalPass);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByDefensePassContaining
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefensePassContaining(String defensePass) throws DataAccessException {

		return findThesisstatusByDefensePassContaining(defensePass, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByDefensePassContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefensePassContaining(String defensePass, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByDefensePassContaining", startResult, maxRows, defensePass);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByProposalDate
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalDate(java.util.Calendar proposalDate) throws DataAccessException {

		return findThesisstatusByProposalDate(proposalDate, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByProposalDate
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalDate(java.util.Calendar proposalDate, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByProposalDate", startResult, maxRows, proposalDate);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByDefenseDate
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefenseDate(java.util.Calendar defenseDate) throws DataAccessException {

		return findThesisstatusByDefenseDate(defenseDate, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByDefenseDate
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefenseDate(java.util.Calendar defenseDate, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByDefenseDate", startResult, maxRows, defenseDate);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByCommentsContaining
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByCommentsContaining(String comments) throws DataAccessException {

		return findThesisstatusByCommentsContaining(comments, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByCommentsContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByCommentsContaining(String comments, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByCommentsContaining", startResult, maxRows, comments);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByPrimaryKey
	 *
	 */
	@Transactional
	public Thesisstatus findThesisstatusByPrimaryKey(Integer thesisStatusId) throws DataAccessException {

		return findThesisstatusByPrimaryKey(thesisStatusId, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByPrimaryKey
	 *
	 */

	@Transactional
	public Thesisstatus findThesisstatusByPrimaryKey(Integer thesisStatusId, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findThesisstatusByPrimaryKey", startResult, maxRows, thesisStatusId);
			return (edu.unf.cen6940.domain.Thesisstatus) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findThesisstatusByProposalPassContaining
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalPassContaining(String proposalPass) throws DataAccessException {

		return findThesisstatusByProposalPassContaining(proposalPass, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByProposalPassContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposalPassContaining(String proposalPass, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByProposalPassContaining", startResult, maxRows, proposalPass);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllThesisstatuss
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findAllThesisstatuss() throws DataAccessException {

		return findAllThesisstatuss(-1, -1);
	}

	/**
	 * JPQL Query - findAllThesisstatuss
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findAllThesisstatuss(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllThesisstatuss", startResult, maxRows);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByProposed
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposed(String proposed) throws DataAccessException {

		return findThesisstatusByProposed(proposed, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByProposed
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposed(String proposed, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByProposed", startResult, maxRows, proposed);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByDefensePass
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefensePass(String defensePass) throws DataAccessException {

		return findThesisstatusByDefensePass(defensePass, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByDefensePass
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefensePass(String defensePass, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByDefensePass", startResult, maxRows, defensePass);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByProposedContaining
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposedContaining(String proposed) throws DataAccessException {

		return findThesisstatusByProposedContaining(proposed, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByProposedContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByProposedContaining(String proposed, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByProposedContaining", startResult, maxRows, proposed);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByDefendedContaining
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefendedContaining(String defended) throws DataAccessException {

		return findThesisstatusByDefendedContaining(defended, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByDefendedContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByDefendedContaining(String defended, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByDefendedContaining", startResult, maxRows, defended);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByComments
	 *
	 */
	@Transactional
	public Set<Thesisstatus> findThesisstatusByComments(String comments) throws DataAccessException {

		return findThesisstatusByComments(comments, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByComments
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Thesisstatus> findThesisstatusByComments(String comments, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findThesisstatusByComments", startResult, maxRows, comments);
		return new LinkedHashSet<Thesisstatus>(query.getResultList());
	}

	/**
	 * JPQL Query - findThesisstatusByThesisStatusId
	 *
	 */
	@Transactional
	public Thesisstatus findThesisstatusByThesisStatusId(Integer thesisStatusId) throws DataAccessException {

		return findThesisstatusByThesisStatusId(thesisStatusId, -1, -1);
	}

	/**
	 * JPQL Query - findThesisstatusByThesisStatusId
	 *
	 */

	@Transactional
	public Thesisstatus findThesisstatusByThesisStatusId(Integer thesisStatusId, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findThesisstatusByThesisStatusId", startResult, maxRows, thesisStatusId);
			return (edu.unf.cen6940.domain.Thesisstatus) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	public boolean canBeMerged(Thesisstatus entity) {
		return true;
	}
}
